﻿using System;

namespace SeaBattle.Domain.Entities
{
    public class Account
    {
        public decimal Balance { get; private set; }
        public string OwnerLogin { get; private set; }

        public Account(decimal startBalance, string OwnerLogin)
        {
            Balance = startBalance;
            this.OwnerLogin = OwnerLogin;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="amount">Can be a negative</param>
        /// <returns></returns>
        public decimal AddAmount(decimal  amount)
        {
            if(Balance+amount < 0)
            {
                throw new ArithmeticException("Balance amount cannot be negative");
            }
            Balance += amount;
            return Balance;
        }
    }
}
